package com.ruoyi.sl.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.sl.domain.SlFullAttendance;
import com.ruoyi.sl.service.ISlFullAttendanceService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 考勤日期Controller
 * 
 * @author admin
 * @date 2024-06-11
 */
@RestController
@RequestMapping("/sl/fullattendance")
public class SlFullAttendanceController extends BaseController
{
    @Autowired
    private ISlFullAttendanceService slFullAttendanceService;

    /**
     * 查询考勤日期列表
     */
    @PreAuthorize("@ss.hasPermi('sl:fullattendance:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlFullAttendance slFullAttendance)
    {
        startPage();
        List<SlFullAttendance> list = slFullAttendanceService.selectSlFullAttendanceList(slFullAttendance);
        return getDataTable(list);
    }

    /**
     * 导出考勤日期列表
     */
    @PreAuthorize("@ss.hasPermi('sl:fullattendance:export')")
    @Log(title = "考勤日期", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlFullAttendance slFullAttendance)
    {
        List<SlFullAttendance> list = slFullAttendanceService.selectSlFullAttendanceList(slFullAttendance);
        ExcelUtil<SlFullAttendance> util = new ExcelUtil<SlFullAttendance>(SlFullAttendance.class);
        util.exportExcel(response, list, "考勤日期数据");
    }

    /**
     * 获取考勤日期详细信息
     */
    @PreAuthorize("@ss.hasPermi('sl:fullattendance:query')")
    @GetMapping(value = "/{faId}")
    public AjaxResult getInfo(@PathVariable("faId") Long faId)
    {
        return success(slFullAttendanceService.selectSlFullAttendanceByFaId(faId));
    }

    /**
     * 新增考勤日期
     */
    @PreAuthorize("@ss.hasPermi('sl:fullattendance:add')")
    @Log(title = "考勤日期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlFullAttendance slFullAttendance)
    {
        return toAjax(slFullAttendanceService.insertSlFullAttendance(slFullAttendance));
    }

    /**
     * 修改考勤日期
     */
    @PreAuthorize("@ss.hasPermi('sl:fullattendance:edit')")
    @Log(title = "考勤日期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlFullAttendance slFullAttendance)
    {
        return toAjax(slFullAttendanceService.updateSlFullAttendance(slFullAttendance));
    }

    /**
     * 删除考勤日期
     */
    @PreAuthorize("@ss.hasPermi('sl:fullattendance:remove')")
    @Log(title = "考勤日期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{faIds}")
    public AjaxResult remove(@PathVariable Long[] faIds)
    {
        return toAjax(slFullAttendanceService.deleteSlFullAttendanceByFaIds(faIds));
    }
}
